package com.usefullc.english.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.usefullc.common.util.BeanUtils;
import com.usefullc.english.domain.ReplyLike;
import com.usefullc.english.mapper.ReplyLikeMapper;
import com.usefullc.english.query.ReplyLikeQuery;
import com.usefullc.english.vo.ReplyLikeVo;
import com.usefullc.system.entity.Pager;
import com.usefullc.system.service.AbstractBizService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 评论点赞服务类
 * @author: 星空
 * @date: 2022-08-07
 */
@Service
public class ReplyLikeService extends AbstractBizService<ReplyLikeMapper, ReplyLike, ReplyLikeQuery> {


    @Override
    protected QueryWrapper<ReplyLike> getQueryWrapper(ReplyLikeQuery query) {
        QueryWrapper<ReplyLike> queryWrapper = super.getQueryWrapper(query);
        return queryWrapper;
    }

    public Pager<ReplyLikeVo> findVoByPage(ReplyLikeQuery query){
        Pager<ReplyLike> page = this.findByPage(query);
        Pager<ReplyLikeVo> newPage = new Pager<>(page);
        List<ReplyLike> dataList = page.getDataList();
        List<ReplyLikeVo> newDataList = new ArrayList<>();
        newPage.setDataList(newDataList);
        for (ReplyLike replyLike : dataList) {
            ReplyLikeVo replyLikeVo = BeanUtils.beanCopy(replyLike, ReplyLikeVo.class);
            newDataList.add(replyLikeVo);
        }
        return newPage;
    }


}
